#include "client.hpp"

sf::Mutex MutexGlobal;

Client::Client() {
	addresse_server = "127.0.0.1";
	if (client.Connect(Port, addresse_server) != sf::Socket::Done) {
		std::cerr << "Erreur : connexion impossible" << std::endl;
	}	
	std::cout << "Connecté au serveur" << std::endl;

}

void Client::Run() {
	char toSend[] = "msg";
	for (int i = 0; i < 5; i++) {
		if (client.Send(toSend, sizeof(toSend)) != sf::Socket::Done) {
		std::cerr << "Erreur : envoie de message impossible" << std:: endl;
		}
	sleep(1);	
	}
	char endMsg[] = "END";
	if (client.Send(endMsg, sizeof(endMsg)) != sf::Socket::Done) {
		std::cerr << "Erreur : envoie de message impossible" << std:: endl;
	}
	client.Close();
}


